//
//  ProxyManager.m
//  StoreProject
//
//  Created by caoyicheng on 2021/4/15.
//

#import "ProxyManager.h"

@implementation ProxyManager

- (BOOL)getProxyStatus {
    NSDictionary *proxySettings = CFBridgingRelease(CFNetworkCopySystemProxySettings());
    NSArray *proxies = (NSArray *)CFBridgingRelease(CFNetworkCopyProxiesForURL((CFURLRef)CFBridgingRetain([NSURL URLWithString:@"http://www.baidu.com"]), (CFDictionaryRef)CFBridgingRetain(proxySettings)));
    NSDictionary *settings = [proxies objectAtIndex:0];
    
//    NSLog(@"host=%@", [settings objectForKey:(NSString *)kCFProxyHostNameKey]);
//    NSLog(@"port=%@", [settings objectForKey:(NSString *)kCFProxyPortNumberKey]);
//    NSLog(@"type=%@", [settings objectForKey:(NSString *)kCFProxyTypeKey]);
    
    id value = [[NSUserDefaults standardUserDefaults] valueForKey:@"kDeveloperFlag"];
    BOOL flag = NO;
    if (value == nil) {
        flag = NO;
    } else {
        
        if ([value isEqual:@(1)]) {
            flag = YES;
        } else {
            flag = NO;
        }
    }
    
    if (flag == YES) {
        
        return NO;
    }
    
    if ([[settings objectForKey:(NSString *)kCFProxyTypeKey] isEqualToString:@"kCFProxyTypeNone"])
    {
        //没有设置代理
        return NO;
    }
    else
    {
        //设置代理了
        return YES;
    }
}


@end
